import request from '@/utils/request'

// 创建支付订单
export function createPaymentOrder(data) {
  return request({
    url: '/api/payment/create',
    method: 'post',
    data
  })
}

// 获取订单列表
export function getOrderList(params) {
  return request({
    url: '/api/payment/orders',
    method: 'get',
    params
  })
}

// 获取订单详情
export function getOrderDetail(orderNo) {
  return request({
    url: `/api/payment/orders/${orderNo}`,
    method: 'get'
  })
}

// 查询支付状态
export function queryPaymentStatus(orderNo) {
  return request({
    url: `/api/payment/status/${orderNo}`,
    method: 'get'
  })
}

// 取消订单
export function cancelOrder(orderNo) {
  return request({
    url: `/api/payment/cancel/${orderNo}`,
    method: 'post'
  })
}

// 申请退款
export function refundPayment(orderNo, reason) {
  return request({
    url: `/api/payment/refund/${orderNo}`,
    method: 'post',
    data: { reason }
  })
}

// 获取支付二维码
export function getPaymentQrCode(orderNo) {
  return request({
    url: `/api/payment/qrcode/${orderNo}`,
    method: 'get'
  })
}

// 获取支付配置
export function getPaymentConfig() {
  return request({
    url: '/api/payment/config',
    method: 'get'
  })
}
